import type { Criteria } from '@/types/filtrate-condition';
import { isEmpty } from '@/utils/util';
export function getQueryParams(criteriaList : Criteria[]) {
	const query : Record<string, any> = {};
	for (const item of criteriaList) {
		if (isEmpty(item.value)) {
			continue;
		}
		if (['radio', 'input', 'date', 'checkbox'].includes(item.type)) {
			query[item.field as string] = item.value;
			continue;
		}

		if (['rangeInput', 'daterange'].includes(item.type)) {
			const [key1, key2] = item.field;
			const [value1, value2] = item.value;
			if (!isEmpty(key1) && !isEmpty(value1)) {
				query[key1] = value1;
			}

			if (!isEmpty(key2) && !isEmpty(value2)) {
				query[key2] = value2;
			}
		}
	}
	return query;
}